package com.k.demo.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.k.demo.entity.RedBag;

@Mapper
public interface RedBagMapper {
	
	//查找全部
	@Select("select * from red_bag where is_delete=1 or is_delete = 2")
	List<RedBag> getAllRedBags();
	
	//根据红包id，获取对应的红包信息
	@Select("select * from red_bag where (is_delete=1 or is_delete=2) and red_bag_id = #{red_bag_id}")
	List<RedBag> getRedBagById(Integer red_bag_id);
	
	//根据当前用户会员等级以及用户id来显示可领取红包
	@Select("select * from red_bag where is_delete=1 and available_level <= #{available_level}")
	List<RedBag> getByIdAndLevel(Integer available_level);
	
	//创建新的红包
	int addRedBag(RedBag redBag);
	
	//修改红包的信息
//	int modifyRedBag(RedBag redBag);
	
	//根据传入的红包对象进行查询
	List<RedBag> getByRedBag(RedBag redBag);
	
	@Select("select nvl(face_value,0) from red_bag where red_bag_id=#{red_bag_id} and is_delete = 1")
	Double getValueById(int red_bag_id);
	
	//显示当前用户可领红包
	List<RedBag> getAvailableRedBag(Integer user_id);
	
	//查找成为会员时自动发送的红包
	@Select("select * from red_bag where is_delete = 2")
	List<RedBag> getVipRedBags();
}
